home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1984 August
/
1984-08.d64
/
string search 2
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
806b
|
36 lines
20 a$="dummy data":rem must be a string
30 q$="":rem this is to be used as the search string
40 dima$(300),q%(300):rem searched string and flag array
45 ml=peek(55)+256*peek(56):rem start address
100 print"building array"
110 q$="good"
120 forl=1to299
130 :
140 :a$(l)="abcdefghijklmnopqrstuvwxyz"
150 :
160 nextl
170 a$(1)="garbage good more garbage"
180 a$(10)="garb good more garb"
185 a$(70)="good garbage"
190 a$(100)="garbage good"
195 a$(250)="garbage good more garbage"
200 print"array finished"
300 rem basic search
310 print"basic search":ti$="000000"
320 forl=1to299
330 :forj=1tolen(a$(l))-len(q$)+1
340 ::ifmid$(a$(l),j,len(q$))=q$thenq%(l)=1:nextl
350 :nextj
360 nextl
370 printti;"jiffies"
380 forl=1to299
390 :ifq%(l)<>0thenprinta$(l)
395 nextl
400 rem ml search
410 print"ml search":ti$="000000"
420 sys(ml)
430 printti;"jiffies"
440 forl=1to299
450 :ifq%(l)<>0thenprinta$(l)
460 nextl